import time

from selenium import webdriver
from selenium.webdriver.edge.service import Service

if __name__ == '__main__':
    exe_path = "../driver/msedgedriver.exe"
    service = Service(executable_path=exe_path)
    brower = webdriver.Edge(service=service)

    # 设置窗口最大化显示
    # brower.maximize_window()
    brower.get(url="https://www.baidu.com")
    # 睡眠 10 秒
    time.sleep(10)
    brower.set_window_position(800, 600)
    # 设置窗口宽度和高度
    brower.set_window_size(1024,768)
    # 将窗口保存为图片
    brower.save_screenshot("baidu.png")

    # 获取页面的标题
    title = brower.title
    print(title)
    # 获取页面的源代码
    html = brower.page_source
    print(html)

    # 退出
    brower.quit()
